package com.itany.corejava.code07_面向对象.租车系统;

import java.util.Scanner;

/**
 * @author MissChen
 * @version 1.0
 * @date 2023 年11月06日 17:00
 */
public class Test {
    public static void main(String[] args) {
        System.out.println("****************欢迎来使用租车系统***************");
        Scanner sc = new Scanner(System.in);
        MotorVehicle[] vehicles = new MotorVehicle[200];//准备一个机动车类，用于存储租赁的车辆的信息
        int index = 0;//机动车的索引
        // 1.进入租车系统，输入顾客的信息
        System.out.print("请输入您的姓名:");
        String name = sc.next();
        System.out.print("请输入您的手机号码:");
        String phone = sc.next();
        Customer customer = new Customer(name, phone);

        // 2.选择需要租赁的汽车类型(轿车、客车、退出)以及具体的车型(根据选择的类型不同展示不同的车型)
        while (true) {
            System.out.println("请选择需要租赁的机动车类型(1.轿车 2.客车 3.退出)");
            int choice = sc.nextInt();
            if (choice == 1) {
                //请输入租赁的轿车的类型
                System.out.println("请选择轿车的型号:(1.宝马X1 2.奔驰GLC 3.保时捷帕拉梅拉 4.劳斯莱斯幻影):");
                int num = sc.nextInt();
                switch (num) {
                    case 1:
                        MotorVehicle vehicle = new Car("苏A66666", "宝马", CarConstant.BMW_X1);
                        vehicles[index++] = vehicle;
                        break;
                    case 2:
                        MotorVehicle vehicle2 = new Car("苏A66667", "奔驰", CarConstant.BENZ_GLC);
                        vehicles[index++] = vehicle2;
                        break;
                    case 3:
                        MotorVehicle vehicle3 = new Car("苏A66668", "保时捷", CarConstant.PORSCHE_PARAMERA);
                        vehicles[index++] = vehicle3;
                        break;
                    case 4:
                        MotorVehicle vehicle4 = new Car("苏A666669", "劳斯莱斯", CarConstant.ROLLS_ROYCE);
                        vehicles[index++] = vehicle4;
                        break;
                    default:
                        System.out.println("您输入的选项有误，请重新输入");
                        break;
                }
            } else if (choice == 2) {
                System.out.println("请选择轿车的型号:(1.20座考斯特 2.25座奔驰凌特 3.35座宇通客车 4.45座金龙客车):");
                int num=sc.nextInt();
                switch (num){
                    case 1:
                        MotorVehicle vehicle=new Bus("苏A10001","考斯特",20);
                        vehicles[index++]=vehicle;
                        break;
                    case 2:
                        MotorVehicle vehicle2=new Bus("苏A10002","奔驰凌特",25);
                        vehicles[index++]=vehicle2;
                        break;
                    case 3:
                        MotorVehicle vehicle3=new Bus("苏A10003","宇通",35);
                        vehicles[index++]=vehicle3;
                        break;
                    case 4:
                        MotorVehicle vehicle4=new Bus("苏A10004","金龙",45);
                        vehicles[index++]=vehicle4;
                        break;
                }

            } else if (choice == 3) {
                break;
            }else{
                System.out.println("您输入的选项有误，请重新输入");
            }
        }


        //3.输入租赁的天数
        System.out.println("请输入您要租赁的天数:");
        int day=sc.nextInt();
        System.out.println("-------------顾客您好，您的姓名是:"+customer.getName()+",您租了以下的车辆:--------------");
        System.out.println("车牌\t\t\t品牌");
        double money=0;//总金额
        for(int i=0;i<index;i++){
            System.out.println(vehicles[i].getNo()+"\t\t\t"+vehicles[i].getBrand());
            money=money+vehicles[i].rent(day);
        }
        System.out.println("您一共的租金是:"+money+"元");




    }
}
